|
|
|
|
|
|
|
Figure 19.1.
ODBC versus Microsoft Jet interface. |
|
|
|
|
|
|
|
|
The ODBC interface doesn't really talk to databases. Instead, it links your Visual Basic program to defined data sources. These sources of data can be flat-file databases (such as dBASE and FoxPro), relational databases (such as Microsoft Access and SQL Server), or any file format for which an ODBC interface driver is available. Microsoft provides an ODBC interface driver for Excel spreadsheets and even delimited text files, for example. As long as a driver is available, you can use ODBC to access the data. |
|
|
|
|
|
|
|
|
Even more important, when you use the ODBC interface to link to a data source, your Visual Basic program is not really talking to the data source directly. Your program talks to the ODBC front-end alone. The ODBC front-end uses removable drivers to translate your requests into a format understood by the target data source. The ODBC drivers exist as a middleman between the ODBC front-end and the target data file. Your Visual Basic programs talk to the ODBC front-end. The ODBC front-end talks to the appropriate driver. The driver talks to the target data file. The advantage of this design is that you easily can replace the translator routines (the drivers) to add improved performance or functionality without having to change your Visual Basic program or the target data source. Also, because the ODBC interface rules are published information, anyone who wants to make data available to users can create a new driver, and that driver then can work with all the installed versions of the ODBC interface that already exist. |
|
|
|
|
|
|
|
|
Using the ODBC API interface has its limits, however. When you use the basic ODBC API to select and retrieve data, you actually are dealing with Snapshot-type data objects. You collect a set of data, bring it to your machine, make additions or modifications to the dataset, and send those changes back to the data source. Although this method is fast, it can be a bit cumbersome. Also, when you use the ODBC API, you are not able to use any data-bound controls. You are responsible for reading the data, placing it into form controls, and moving the data from the form controls back to the data source when needed. This means that you have more programming to do before you get a data-entry form up and running. Even with these drawbacks, using the ODBC API to access your data can add increased flexibility to your Visual Basic database programs. |
|
|
|
|
|